package org.bright.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import freemarker.template.utility.StringUtil;
import org.bright.entity.Employees;
import org.bright.entity.PageResult;
import org.bright.mapper.EmployeesMapper;
import org.bright.service.IEmployeesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author bright
 * @since 2024-12-09 10:12
 */
@Service
public class EmployeesServiceImpl extends ServiceImpl<EmployeesMapper, Employees> implements IEmployeesService {
    @Autowired
    private EmployeesMapper employeesMapper;

    @Override
    public PageResult<Employees> selectPage(Integer pageNum, Employees employees) {
        Page<Employees> page = new Page<>(pageNum,5);
        QueryWrapper<Employees> queryWrapper = new QueryWrapper<>();
        if(StringUtils.isNotEmpty(employees.getEmpName())){
            queryWrapper.like("emp_name",employees.getEmpName());
        }
        if(StringUtils.isNotEmpty(employees.getLoginName())){
            queryWrapper.like("login_name",employees.getLoginName());
        }
        Page<Employees> employeesPage = employeesMapper.selectPageCustom(page, queryWrapper);
        PageResult pageResult = new PageResult(employeesPage);
        return pageResult;
    }
}
